<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit|ie-comp|ie-stand"></meta>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></meta>
<meta http-equiv="Cache-Control" content="no-siteapp" />
 <link href="${pageContext.request.contextPath}/adminfile/assets/css/bootstrap.min.css" rel="stylesheet" />
        <link rel="stylesheet" href="${pageContext.request.contextPath}/adminfile/css/style.css"/>       
        <link href="${pageContext.request.contextPath}/adminfile/assets/css/codemirror.css" rel="stylesheet"> </link>
        <link rel="stylesheet" href="${pageContext.request.contextPath}/adminfile/assets/css/ace.min.css"/> 
        <link rel="stylesheet" href="${pageContext.request.contextPath}/adminfile/font/css/font-awesome.min.css"/> 
		<script src="${pageContext.request.contextPath}/adminfile/js/jquery-1.9.1.min.js"></script>
        <script src="${pageContext.request.contextPath}/adminfile/assets/js/bootstrap.min.js"></script>
		<script src="${pageContext.request.contextPath}/adminfile/assets/js/typeahead-bs2.min.js"></script>           	
		<script src="${pageContext.request.contextPath}/adminfile/assets/js/jquery.dataTables.min.js"></script>
		<script src="${pageContext.request.contextPath}/adminfile/assets/js/jquery.dataTables.bootstrap.js"></script>
        <script src="${pageContext.request.contextPath}/adminfile/assets/layer/layer.js" type="text/javascript" ></script>          
        <script src="${pageContext.request.contextPath}/adminfile/assets/laydate/laydate.js" type="text/javascript"></script>
<title>库存详情</title>
</head>
<body>
<div class="page-content clearfix">
    <div id="Member_Ratings">
      <div class="d_Confirm_Order_style">
    <div class="search_style">
     <form action="selectByartAdddate" method="post">
      <ul class="search_content clearfix">
       <li><label class="l_f">添加时间</label> <input type="text" name="artAdddate"  class="inline laydate-icon" id="start" style=" margin-left:10px;"/></li>
       <li style="width:90px;"><button type="submit" class="btn_search"><i class="icon-search"></i>查询</button></li>
      </ul>
      </form>
    </div>
     <!---->
     <div class="border clearfix">
       <span class="l_f">
        <a href="supplier" id="supplier" class="btn btn-warning"><i class="fa fa-plus"></i>入库</a>
       </span>
       
     </div>
     <!---->
     <div class="table_menu_list">
       <table class="table table-striped table-bordered table-hover" id="sample-table">
<thead>
		<tr>
          <th width="25"><label><input type="checkbox" class="ace"/><span class="lbl"></span></label></th>
          <th width="150">库存编号</th>
          <th width="150px">艺术品Id</th>
          <th width="">艺术品数量</th>
          <th width="250px">入库时间</th>
          <th width="120">供应商名称</th>                
          <th width="200">操作</th>
          </tr>
		</thead>
            <c:forEach items="${list}" var="p" >
              <tr>
              <th width="25px"><label><input type="checkbox" class="ace"/><span class="lbl"></span></label></th>
              <td id="text_a">${p.stockId} </td>
              <td id="text_b"> ${p.artId}</td>
              <td id="text_c">${p.artSum}</td>
              <td id="text_d"> ${p.artAdddate}</td>
              <td id="text_e"> ${p.supplierName}</td>
               <td class="td-manage">
              <a  title="修改" onclick="member_edit('550',this)" href="javascript:;" class="btn btn-xs btn-info" ><i class="fa fa-edit bigger-150"></i></a>      
              <a  title="删除" href="javascript:;"  onclick="member_del(this,'${p.stockId}')" class="btn btn-xs btn-warning" ><i class="fa fa-trash  bigger-150"></i></a>
          </td>
		</tr>
         </c:forEach> 
	</table>
   </div>
  </div>
 </div>
</div>
 <!--修改库存图层-->
<div class="add_menber" id="add_menber_style" style="display:none">
  <form action="" method="post" id="form">
  <ul>
   <span class="name"><input type="hidden" id="text0" value="${p.stockId}" name="stockId"/></span>
   <li><label class="label_name">艺术品Id：</label><span class="name"><input id="text1"  type="text" value="${p.artId}" name="artId"/></span></li>
   <li><label class="label_name">艺术品数量：</label><span class="name"><input id="text2" type="text" value="${p.artSum}" name="artSum"/></span></li>
   <li><label class="label_name">添加时间：</label><span class="name"><input id="text3" type="text" value="${p.artAdddate}" name="artAdddate"/></span></li>
   <li><label class="label_name">供应商：</label><span class="name"><input  id="text4" type="text"  name="supplierName"value="${p.supplierName}"/></span></li>  
  </ul> 
  </form>
 </div>
</body>
<script type="text/javascript">	
jQuery(function($) {
				var oTable1 = $('#sample-table').dataTable( {
				"aaSorting": [[ 1, "desc" ]],//默认第几个排序
		"bStateSave": true,//状态保存
		"aoColumnDefs": [
		  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
		  {"orderable":false,"aTargets":[0,2,3,5,6]}// 制定列不参与排序
		] } );
				
				
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
				});
			
			
				$('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
				function tooltip_placement(context, source) {
					var $source = $(source);
					var $parent = $source.closest('table')
					var off1 = $parent.offset();
					var w1 = $parent.width();
			
					var off2 = $source.offset();
					var w2 = $source.width();
			
					if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
					return 'left';
				}
			})
/*用户-编辑*/
function member_edit(id,t){
	  $("#text0").val($(t).closest("tr").find("#text_a").text());
	  $("#text1").val($(t).closest("tr").find("#text_b").text());
	  $("#text2").val($(t).closest("tr").find("#text_c").text());
	  $("#text3").val($(t).closest("tr").find("#text_d").text());
	  $("#text4").val($(t).closest("tr").find("#text_e").text());
	  layer.open({
        type: 1,
        title: '修改库存信息',
		maxmin: true, 
		shadeClose:false, //点击遮罩关闭层
        area : ['800px' , ''],
        content:$('#add_menber_style'),
		btn:['提交','取消'],
		yes:function(index,layero){	
		 var num=0;
		 var str="";
     $(".add_menber input[type$='text']").each(function(n){
          if($(this).val()=="")
          {
               
			   layer.alert(str+=""+$(this).attr("name")+"不能为空！\r\n",{
                title: '提示框',				
				icon:0,								
          }); 
		    num++;
            return false;            
          } 
		 });
		  if(num>0){  return false;}	 	
          else{
        	  $.ajax({
     	         type: "POST",
     	         url: "updatestock",
     	         data: $('#form').serialize(),
     	         success: function (date) {
     	        	if(date=="success")
     	        		{
     	        	 layer.alert("修改成功！",{
     	                 title: '提示框',				
     	  			icon:1,		
     	  			  });
     	        	 
     	        	     $(t).closest("tr").find("#text_b").text($("#text1").val());
     	                 $(t).closest("tr").find("#text_c").text($("#text2").val());
	                     $(t).closest("tr").find("#text_d").text($("#text3").val());
	                     $(t).closest("tr").find("#text_e").text($("#text4").val());
	                    
     	        		}	 
     	         }
     	     })

			   layer.close(index);
		  }		  		     				
		}
   });
	  
}
/*用户-删除*/
function member_del(obj,stockId){
	layer.confirm('确认要删除吗？',function(index){
		  $.ajax({
 	         type: "POST",
 	         url: "${pageContext.request.contextPath}/deletestock",
 	         data: {"stockId":stockId},
 	         success: function (date) {
 	        	if(date=="success")
 	        		{
 	        		  $(obj).parents("tr").remove();
 	       		      layer.msg('已删除!',{icon:1,time:1000});
 	        		}	 
 	         }
 	     });
	});
}
laydate({
    elem: '#start',
    event: 'focus' 
});
</script>
</html>